part of '../../repository.dart';

const _kAppStoreIssueWithinAppTransactionRevocationReasonValue = 'issue_within_app';
const _kAppStoreOtherReasonTransactionRevocationReasonValue = 'other_reason';

class _AppStoreTransactionRevocationReasonDto extends Equatable {
  const _AppStoreTransactionRevocationReasonDto._internal({
    required this.revocationReasonString,
  });

  final String revocationReasonString;

  @override
  List<Object?> get props {
    return [
      revocationReasonString,
    ];
  }

  factory _AppStoreTransactionRevocationReasonDto.fromString(String revocationReasonString) {
    return _AppStoreTransactionRevocationReasonDto._internal(
      revocationReasonString: revocationReasonString,
    );
  }

  AppStoreTransactionRevocationReason toEntity() {
    return switch (revocationReasonString) {
      _kAppStoreIssueWithinAppTransactionRevocationReasonValue =>
        AppStoreTransactionRevocationReason.issueWithinApp,
      _kAppStoreOtherReasonTransactionRevocationReasonValue =>
        AppStoreTransactionRevocationReason.otherReason,
      _ => throw UnimplementedError(),
    };
  }

  @override
  String toString() {
    return revocationReasonString;
  }
}
